<template>
  <div style="padding-bottom: 50px;">
        
        <van-tabs v-model="activeTwo" animated sticky :swipeable="true" >
          <van-tab title="新任务" >
            
            <van-pull-refresh v-model="isLoading" @refresh="onRefresh">
              <van-empty description="暂无订单" v-if="nullStateShow" />
                <div class="div1">
                  <div class="order-Moduleone-content" v-for="(item, index) in order" :key="index" @click="shopOrder(item.orderId)">
                    <van-cell-group inset>
                    <van-cell>
                      <van-col span="24" style="font-size: 22px; color: orange"><b>订单号:{{item.orderId}}</b></van-col><!-- 数据 -->
                      <van-col span="16" style="font-size: 12px;"><b>立即送达 / {{ item.orderDatetime }} 前送达</b></van-col><!-- 数据 -->
                      <!-- <van-col span="8" style="font-size: 20px;"><b>待骑手接单</b></van-col> -->
                    </van-cell>

                    <van-cell>
                      <van-col span="5" style="font-size: 20px"><b>{{item.unickname}}先生</b></van-col><!-- 数据 -->
                      <van-col span="13"><b>手机尾号:{{item.uphone}}</b></van-col><!-- 数据 -->
                      <van-col span="3"><img src="../../assets/img/电话_填充.png" ></van-col>
                      <van-col span="3"><img src="../../assets/img/消息2.png" ></van-col>
                      <van-col span="24" style="font-size: 12px" v-if="!isShow"><b>0.00km | 点击查看配送地址</b></van-col>
                      <van-col span="24" style="font-size: 12px" v-else><b>{{ (item.route.distance / 1000).toFixed(2)  }}km | 点击查看配送地址</b></van-col><!-- 数据 -->
                    </van-cell>

                    <van-cell>
                      <van-col span="4"><b style="font-size: 12px;background-color:#e07212;padding:3px; color: white;">备注</b></van-col>
                      <van-col span="20" style="font-size: 20px"><b>顾客需要餐具</b></van-col>
                    </van-cell>

                    <van-cell>
                      <van-col span="1"><b style="font-size: 16px;">{{ item.orderDetails.length }}</b></van-col><!-- 数据 -->
                      <van-col span="5"><b style="font-size: 16px;">种商品，</b></van-col>
                      <van-col span="7" style="font-size: 16px"><b>共{{ item.itemCount }}件</b></van-col><!-- 数据 -->
                      <van-col span="5" style="font-size: 16px"><b>预计收入</b></van-col>
                      <van-col span="5" style="font-size: 16px"><b>￥{{ item.totalPrice }}</b></van-col><!-- 数据 -->
                    </van-cell>

                    <van-cell>
                      <div style="text-align: right;">
                        <van-button size="normal" 
                          style="width: 80px;height: 30px;"
                          @click.stop="updateShopOrderStatus(item.orderId,10)">
                          <b>拒单</b>
                        </van-button>
                        <van-button size="normal" 
                          style="width: 80px;background-color: #FFDD4D;
                          margin-left: 5px;height: 30px;"
                          @click.stop="updateShopOrderStatus(item.orderId,2)">
                          <b>接单</b>
                        </van-button>
                      </div>
                    </van-cell> 
                  </van-cell-group>
                  </div>
                </div>
            </van-pull-refresh>
                
         </van-tab>
              <!-- 骑手待接单 -->
              <van-tab title="骑手待接单">
              <van-pull-refresh v-model="isLoading" @refresh="onRefresh">
                <van-empty description="暂无订单" v-if="nullStateShow2" />
                  <div class="div1">
                    <div class="order-Moduleone-content" v-for="(r,index) in riderOrder" :key="index">
                        <van-cell-group inset>
                        <van-cell>
                          <van-col span="24" style="font-size: 22px; color: orange"><b>订单号:{{r.orderId}}</b></van-col><!-- 数据 -->
                          <van-col span="16" style="font-size: 12px;"><b>立即送达 / {{ r.orderDatetime }} 前送达</b></van-col><!-- 数据 -->
                          <van-col span="8" style="font-size: 20px; color: #ffdd00;"><b>待骑手接单</b></van-col>
                        </van-cell>

                        <van-cell>
                          <van-col span="5" style="font-size: 20px"><b>{{r.unickname}}先生</b></van-col><!-- 数据 -->
                          <van-col span="13"><b>手机尾号:{{r.uphone}}</b></van-col><!-- 数据 -->
                          <van-col span="3"><img src="../../assets/img/电话_填充.png" ></van-col>
                          <van-col span="3"><img src="../../assets/img/消息2.png" ></van-col>
                          <van-col span="24" style="font-size: 12px" v-if="!isShow2"><b>0.00km | 点击查看配送地址</b></van-col>
                      <van-col span="24" style="font-size: 12px" v-else><b>{{ (r.route.distance / 1000).toFixed(2)  }}km | 点击查看配送地址</b></van-col><!-- 数据 -->
                        </van-cell>

                        <!-- <van-cell>
                          <van-col span="24" style="font-size: 16px"><b>已上报出餐完成，出餐用时 </b><b style="color: orange;">00:02:40</b></van-col>
                        </van-cell> -->

                        <van-cell>
                          <van-col span="4"><b style="font-size: 12px;background-color:#e07212;padding:3px; color: white;">备注</b></van-col>
                          <van-col span="20" style="font-size: 20px"><b>顾客需要餐具</b></van-col>
                        </van-cell>

                        <van-cell>
                          <van-col span="1"><b style="font-size: 16px;">{{ r.orderDetails.length }}</b></van-col><!-- 数据 -->
                          <van-col span="5"><b style="font-size: 16px;">种商品，</b></van-col>
                          <van-col span="7" style="font-size: 16px"><b>共{{ r.itemCount }}件</b></van-col><!-- 数据 -->
                          <van-col span="5" style="font-size: 16px"><b>预计收入</b></van-col>
                          <van-col span="5" style="font-size: 16px"><b>￥{{ r.totalPrice }}</b></van-col><!-- 数据 -->
                        </van-cell>

                        <van-cell>
                          <van-row>
                            <van-col span="3">
                              <van-tag type="warning">抢先</van-tag>
                            </van-col>
                            <van-col span="3">
                              <van-tag type="primary">同城</van-tag>
                            </van-col>
                          </van-row>
                        </van-cell>

                        <van-cell>
                          <van-button
                            size="mini"
                            style="
                            width: 100%;
                            height: 40px;
                            background-color: #ffdd00;
                            font-size: 15px;"
                            ><b>联系骑手</b></van-button>
                        </van-cell> 
                    </van-cell-group>
                    </div>
                  </div>
              </van-pull-refresh>
            
          </van-tab>

          <!-- 骑手接单 -->
          <van-tab title="骑手接单">
            <van-pull-refresh v-model="isLoading" @refresh="onRefresh">
              <van-empty description="暂无订单" v-if="nullStateShow3" />
              <div class="div1">
                <div class="order-Moduleone-content" v-for="(r,index) in receivedOrders" :key="index">
                  <van-cell-group inset>
                  <van-cell>
                    <van-col span="24" style="font-size: 22px; color: orange"><b>订单号:{{r.orderId}}</b></van-col><!-- 数据 -->
                    <van-col span="16" style="font-size: 12px;"><b>立即送达 / {{ r.orderDatetime }} 前送达</b></van-col><!-- 数据 -->
                    <van-col span="8" style="font-size: 20px;"><b>骑手已接单</b></van-col>
                  </van-cell>

                  <van-cell>
                    <van-col span="5" style="font-size: 20px"><b>{{r.unickname}}先生</b></van-col><!-- 数据 -->
                    <van-col span="13"><b>手机尾号:{{r.uphone}}</b></van-col><!-- 数据 -->
                    <van-col span="3"><img src="../../assets/img/电话_填充.png" ></van-col>
                    <van-col span="3"><img src="../../assets/img/消息2.png" ></van-col>
                    <van-col span="24" style="font-size: 12px" v-if="!isShow3"><b>0.00km | 点击查看配送地址</b></van-col>
                      <van-col span="24" style="font-size: 12px" v-else><b>{{ (r.route.distance / 1000).toFixed(2)  }}km | 点击查看配送地址</b></van-col><!-- 数据 -->
                  </van-cell>

                  <!-- <van-cell>
                    <van-col span="24" style="font-size: 16px"><b>已上报出餐完成，出餐用时 </b><b style="color: orange;">00:02:40</b></van-col>
                  </van-cell> -->

                  <van-cell>
                    <van-col span="5" style="font-size: 20px"><b>{{ r.riderName }}</b></van-col>
                    <van-col span="13" style="font-size: 20px"><b style="font-size: 14px;background-color:#ffdd00;padding:3px;">美团骑手</b></van-col>
                    <van-col span="3"><img src="../../assets/img/电话_填充.png" ></van-col>
                    <van-col span="3"><img src="../../assets/img/位置.png" ></van-col>
                    <van-col span="24">20:25</van-col>
                  </van-cell>

                  <van-cell>
                    <van-col span="4"><b style="font-size: 12px;background-color:#e07212;padding:3px; color: white;">备注</b></van-col>
                    <van-col span="20" style="font-size: 20px"><b>{{ r.orderRemarks }}</b></van-col>
                  </van-cell>

                  <van-cell>
                    <van-col span="1"><b style="font-size: 16px;">{{ r.orderDetails.length }}</b></van-col><!-- 数据 -->
                    <van-col span="5"><b style="font-size: 16px;">种商品，</b></van-col>
                    <van-col span="7" style="font-size: 16px"><b>共{{ r.itemCount }}件</b></van-col><!-- 数据 -->
                    <van-col span="5" style="font-size: 16px"><b>预计收入</b></van-col>
                    <van-col span="5" style="font-size: 16px"><b>￥{{ r.totalPrice }}</b></van-col><!-- 数据 -->
                  </van-cell>


                  <van-cell>
                    <van-button
                      size="mini"
                      style="
                      width: 100%;
                      height: 40px;
                      background-color: #ffdd00;
                      font-size: 15px;"
                      ><b>完成</b></van-button>
                  </van-cell> 
                </van-cell-group>
              </div>
              </div>
            </van-pull-refresh>
            
          </van-tab>
          <!-- 配送完成 -->
          <van-tab title="配送完成">
            <van-pull-refresh v-model="isLoading" @refresh="onRefresh">
              <van-empty description="暂无订单" v-if="nullStateShow4" />
              <div class="div1">
                <div class="order-Moduleone-content" v-for="(s,index) in successOrder" :key="index">
                    <van-cell-group inset>
                    <van-cell>
                      <van-col span="24" style="font-size: 22px; color: orange"><b>订单号:{{s.orderId}}</b></van-col><!-- 数据 -->
                    </van-cell>

                    <van-cell>
                      <!-- <van-col span="6"></van-col>
                      <van-col span="6"></van-col> -->
                      <van-col span="24" style="font-size: 20px;"><b>骑手配送完成</b></van-col>
                    </van-cell>

                    <van-cell>
                      <van-col span="5" style="font-size: 20px"><b>{{s.unickname}}先生</b></van-col><!-- 数据 -->
                      <van-col span="13"><b>手机尾号:{{s.uphone}}</b></van-col><!-- 数据 -->
                      <van-col span="3"><img src="../../assets/img/电话_填充.png" ></van-col>
                      <van-col span="3"><img src="../../assets/img/消息2.png" ></van-col>
                    </van-cell>

                    <van-cell>
                      <van-col span="5" style="font-size: 20px"><b>{{ s.riderName }}</b></van-col>
                      <van-col span="13" style="font-size: 20px"><b style="font-size: 14px;background-color:#ffdd00;padding:3px;">美团骑手</b></van-col>
                      <van-col span="3"><img src="../../assets/img/电话_填充.png" ></van-col>
                      <van-col span="3"><img src="../../assets/img/位置.png" ></van-col>
                    </van-cell>

                    <van-cell>
                      <van-button
                        size="mini"
                        style="
                        width: 100%;
                        height: 40px;
                        background-color: #ffdd00;
                        font-size: 15px;"
                        ><b>完成</b></van-button>
                    </van-cell> 
                  </van-cell-group>
                </div>
              </div>
            </van-pull-refresh>
          </van-tab>
          <!-- 售后 -->
          <van-tab title="售后">
            <van-pull-refresh v-model="isLoading" @refresh="onRefresh">
              <van-empty description="暂无订单" v-if="nullStateShow5" />
              <div class="div1">
                <van-card
                  price="2.00"
                  desc="商品名称"
                  title="店铺名称"
                  thumb="https://img01.yzcdn.cn/vant/ipad.jpeg"
                >
                  <template #footer>
                    <van-button size="mini">删除订单</van-button>
                    <van-button size="mini">退款进度</van-button>
                  </template>
                </van-card>
              </div>
            </van-pull-refresh>
            
          </van-tab>
        </van-tabs>

    <div style="display: none;">
      <div id="container"></div>
      <div id="panel"></div>
    </div>
  </div>
</template>

<script>
import AMapLoder from "@amap/amap-jsapi-loader"
window._AMapSecurityConfig = {
  securityJsCode: '076a11c5506a73967e139cab3f76629a',
}
import { Toast } from 'vant';
import axios from 'axios';
export default {
  
  name: 'BusinessOrder',
  data(){
    return{
      //空状态属性
      nullStateShow:true,
      nullStateShow2:true,
      nullStateShow3:true,
      nullStateShow4:true,
      nullStateShow5:true,

      active: 0,
      activeTwo:0,
      activethree:0,
      // 商家信息
      shop:this.$store.state.shop,
      // 查询用户已支付的订单
      order:[],
      // 待骑手接单
      riderOrder:[],
      // 已接单
      receivedOrders:[],
      // 配送已完成的订单
      successOrder:[],

      isLoading: false,
      // 新任务
      isShow:false,
      // 商家接单
      isShow2:false,
      // 骑手接单
      isShow3:false,


      map:null,
      riding:null
    };
  },
  methods:{
    shopOrder(orederId){
      this.$router.push({path:`/shopOrderDetails/${orederId}`})
    },
    userOrShopAddress(address) {
      return new Promise((resolve, reject) => {
        axios
          .get(`https://restapi.amap.com/v3/geocode/geo?address=${address}&output=JSON&key=839bfb965ce089afc2306a5e7ee29000`)
          .then(result => {
            const address2 = result.data.geocodes[0].location;
            resolve(address2);
          })
          .catch(error => {
            console.log(error);
            reject(error);
          });
      });
    },
    // 下拉刷新
    onRefresh() {
      setTimeout(() => {
        // 查询用户已支付的订单
        this.queryShopOrder(1);
        setTimeout(() => {
          // 查询商家确认订单 待骑手接单
          this.queryIsRiderOrder(2);
        }, 1500);
        setTimeout(() => {
          // 查询骑手已接的订单
          this.queryRiderOrder(3)
        }, 3000);
        // 查询已完成配送的订单
        this.deliveryCompleted(5)
        Toast('刷新成功');
        this.isLoading = false;
      }, 1000);
    },
  
    // 高德地图
    searchRoute(userAddress,shopAddress) {
      console.log(userAddress);
      console.log(shopAddress);
      const [longitude, latitude] = userAddress.split(",").map(Number);
      const [longitude1, latitude1] = shopAddress.split(",").map(Number);
      return new Promise((resolve, reject) => {
        AMapLoder.load({
          "key": "f77c4299bdb279ff82f9e2b57a0563d3",
          "version": "2.0",
          "plugins": ['AMap.Riding'],
        }).then(AMap => {
          this.map = new AMap.Map("container", {
            resizeEnable: true,
            center: [116.397428, 39.90923],
            zoom: 13
          });
          this.riding = new AMap.Riding({
            map: this.map,
            panel: "panel"
          });
          console.log(longitude,latitude);
          console.log(longitude1,latitude1);
          this.riding.search([longitude,latitude], [longitude1,latitude1], (status, result) => {
            console.log(status);
            if (status === 'complete') {
              console.log("打印成功");
              const route = result.routes && result.routes[0];
              resolve(route); // 返回route
            } else {
              console.log("异常信息 = ", result);
              reject(result);
            }
          });
        })
        .catch(e => {
          console.log(e);
          reject(e);
        });
      });
    },
    
    // 查询配送完成的订单
    deliveryCompleted(status){
      axios.get('/api/shop/Order/listShopIsRiderOrder', {
        params: {
          shopId: this.shop.shopId,
          status
        }
      })
      .then(response => {
        
        // 处理响应数据
        if (response.data.code === 200) {
          
          this.successOrder = response.data.data;
          let itemCount = 0;
          this.successOrder.forEach(o => {
            // 截取手机号
            o.uphone = o.uphone.slice(7, 11)
            // 截取姓
            o.unickname = o.unickname.slice(0, 1)
            // 转成对象
            o.orderDetails = JSON.parse(o.orderDetails)
            // 金额
            o.orderDetails.forEach(x => { itemCount += x.itemNum})
            this.$set(o,"itemCount",itemCount)
            o.totalPrice = (o.totalPrice * 0.8).toFixed(2);
            // 时间
            const { year, month, day } = o.orderDatetime.date;
            const { hour, minute, second } = o.orderDatetime.time;
            const date = new Date(year, month - 1, day, hour, minute, second);
            date.setMinutes(date.getMinutes() + 48 );// + Math.floor(Math.random() * 15) + 1)
            o.orderDatetime =  date.getMonth() + 1 +"-"+ date.getDate()+"  "+ date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', hour12: false });;
          })
          
          console.log(this.successOrder);
        }
        if (this.successOrder.length > 0) {
          console.log(4);
          this.nullStateShow4 = false
        }else{
          this.nullStateShow4 = true
        }
      })
      .catch(error => {
        // 处理错误
        console.error(error);
      });
    },
    // 查询骑手已接单
    queryRiderOrder(status){
      axios.get('/api/shop/Order/listShopIsRiderOrder', {
        params: {
          shopId: this.shop.shopId,
          status
        }
      })
      .then(response => {
        // 处理响应数据
        if (response.data.code === 200) {
          
          this.receivedOrders = response.data.data;
          let itemCount = 0;
          this.receivedOrders.forEach(o => {
            // 截取手机号
            o.uphone = o.uphone.slice(7, 11)
            // 截取姓
            o.unickname = o.unickname.slice(0, 1)
            // 转成对象
            o.orderDetails = JSON.parse(o.orderDetails)
            // 金额
            o.orderDetails.forEach(x => { itemCount += x.itemNum})
            this.$set(o,"itemCount",itemCount)
            o.totalPrice = (o.totalPrice * 0.8).toFixed(2);
            // 时间
            const { year, month, day } = o.orderDatetime.date;
            const { hour, minute, second } = o.orderDatetime.time;
            const date = new Date(year, month - 1, day, hour, minute, second);
            date.setMinutes(date.getMinutes() + 48 );// + Math.floor(Math.random() * 15) + 1)
            o.orderDatetime =  date.getMonth() + 1 +"-"+ date.getDate()+"  "+ date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', hour12: false });;
            // 地图加距离
            Promise.all([
                // 调用用户地址的区号 并存储到order
                this.userOrShopAddress(o.addressDetail),
                // 调用商家地址的区号 并存储到order
                this.userOrShopAddress(o.shopAddress)
              ]).then(addresses => {
                console.log(addresses);
                this.$set(o, "userAreaNumber", addresses[0]);
                this.$set(o, "shopAreaNumber", addresses[1]);
                
                return this.searchRoute(addresses[0], addresses[1]);
              }).then(route => {
                this.$set(o, "route", route);
                this.isShow3 = true
                console.log(route); // 处理返回结果
              }).catch(error => {
                console.log(error); // 处理错误
              });
          })
          
          console.log(this.receivedOrders);
        }
        if (this.receivedOrders.length > 0) {
          console.log(3);
          this.nullStateShow3 = false
        }else{
          this.nullStateShow3 = true
        }
      })
      .catch(error => {
        // 处理错误
        console.error(error);
      });
    }, 
    // 查询商家确认接单了之后，待骑手接单
    queryIsRiderOrder(status){
      axios.get('/api/shop/Order/listShopOrder', {
        params: {
          shopId: this.shop.shopId,
          status
        }
      })
      .then(response => {
       
        // 处理响应数据
        if (response.data.code === 200) {
          
          this.riderOrder = response.data.data;
          let itemCount = 0;
          this.riderOrder.forEach(o => {
            // 截取手机号
            o.uphone = o.uphone.slice(7, 11)
            // 截取姓
            o.unickname = o.unickname.slice(0, 1)
            // 转成对象
            o.orderDetails = JSON.parse(o.orderDetails)
            // 金额
            o.orderDetails.forEach(x => { itemCount += x.itemNum})
            this.$set(o,"itemCount",itemCount)
            o.totalPrice = (o.totalPrice * 0.8).toFixed(2);
            // 时间
            const { year, month, day } = o.orderDatetime.date;
            const { hour, minute, second } = o.orderDatetime.time;
            const date = new Date(year, month - 1, day, hour, minute, second);
            date.setMinutes(date.getMinutes() + 48 );// + Math.floor(Math.random() * 15) + 1)
            o.orderDatetime =  date.getMonth() + 1 +"-"+ date.getDate()+"  "+ date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', hour12: false });
          
            // 地图加距离
            Promise.all([
                // 调用用户地址的区号 并存储到order
                this.userOrShopAddress(o.addressDetail),
                // 调用商家地址的区号 并存储到order
                this.userOrShopAddress(o.shopAddress)
              ]).then(addresses => {
                console.log(addresses);
                this.$set(o, "userAreaNumber", addresses[0]);
                this.$set(o, "shopAreaNumber", addresses[1]);
                
                return this.searchRoute(addresses[0], addresses[1]);
              }).then(route => {
                this.$set(o, "route", route);
                this.isShow2 = true
                console.log(route); // 处理返回结果
              }).catch(error => {
                console.log(error); // 处理错误
              });
          })
          console.log(this.riderOrder);
        }
        if (this.riderOrder.length > 0) {
          this.nullStateShow2 = false
        }else{
          this.nullStateShow2 = true
        }
      })
      .catch(error => {
        // 处理错误
        console.error(error);
      });
    }, 
      // 查询用户已支付的订单
     queryShopOrder(status){
      axios.get('/api/shop/Order/listShopOrder', {
        params: {
          shopId: this.shop.shopId,
          status
        }
      })
      .then(response => {
        // 处理响应数据
        if (response.data.code === 200) {
          this.order = response.data.data;
          let itemCount = 0;
          this.order.forEach(o => {
            // 截取手机号
            o.uphone = o.uphone.slice(7, 11)
            // 截取姓
            o.unickname = o.unickname.slice(0, 1)
            // 转成对象
            o.orderDetails = JSON.parse(o.orderDetails)
            // 金额
            o.orderDetails.forEach(x => { itemCount += x.itemNum})
            this.$set(o,"itemCount",itemCount)
            o.totalPrice = (o.totalPrice * 0.8).toFixed(2);
            // 时间
            const { year, month, day } = o.orderDatetime.date;
            const { hour, minute, second } = o.orderDatetime.time;
            const date = new Date(year, month - 1, day, hour, minute, second);
            date.setMinutes(date.getMinutes() + 48 );// + Math.floor(Math.random() * 15) + 1)
            o.orderDatetime =  date.getMonth() + 1 +"-"+ date.getDate()+"  "+ date.toLocaleTimeString([], { hour: '2-digit', minute: '2-digit', hour12: false });

            // 地图加距离
              Promise.all([
                // 调用用户地址的区号 并存储到order
                this.userOrShopAddress(o.addressDetail),
                // 调用商家地址的区号 并存储到order
                this.userOrShopAddress(o.shopAddress)
              ]).then(addresses => {
                console.log(addresses);
                this.$set(o, "userAreaNumber", addresses[0]);
                this.$set(o, "shopAreaNumber", addresses[1]);
                // setTimeout(() => {
                return this.searchRoute(addresses[0], addresses[1]);
                // }, 500);
              }).then(route => {
                this.$set(o, "route", route);
                this.isShow = true
                console.log(route); // 处理返回结果
              }).catch(error => {
                console.log(error); // 处理错误
              });


          })
          console.log(this.order);
        }
        if (this.order.length > 0) {
          console.log(1);
          this.nullStateShow = false
        }
      })
      .catch(error => {
        // 处理错误
        console.error(error);
      });
    },
    // 修改订单的状态
    updateShopOrderStatus(orderId,status){
      // /shop/Order/updateShopOrderStatus
      axios.defaults.headers['Content-type'] = 'application/x-www-form-urlencoded;charset=utf-8';
      axios.post("/api/shop/Order/updateShopOrderStatus",{
        orderId,
        status
      }).then(result =>{
        if (result.data.code === 200) {
          console.log(result.data);
          this.queryShopOrder(1);
        }
      }).catch(error => {
        // 处理错误
        console.error(error);
      });
    }
  },
  created() {
    // 查询用户已支付的订单
    this.queryShopOrder(1);
    setTimeout(() => {
      // 查询商家确认订单 待骑手接单
      this.queryIsRiderOrder(2);
    }, 1500);
    setTimeout(() => {
      // 查询骑手已接的订单
      this.queryRiderOrder(3)
    }, 3000);
    
    
    // 查询已完成配送的订单
    this.deliveryCompleted(5)
    
    // console.log(this.userOrShopAddress("广东省珠海市斗门区白蕉镇南方it学院"));
    // console.log(this.userOrShopAddress("珠海市斗门区井岸镇中兴中路93号"));
    
    
    // this.searchRoute("113.326826,22.203555","113.298327,22.210791").then(route => {
    //   console.log(route); // 处理返回结果
    // }).catch(error => {
    //   console.log(error); // 处理错误
    // });
  },
}
</script>
  
<style scoped>
.div1{
  height: 800px;
  max-height: 800;
  overflow-y: auto;
  margin-top: 10px;
}
 .w{
   width: 400px;
 }
 .order-Moduleone-content{
   width: 95%;
   margin: 0 auto;
   margin-top: 10px;
   border-radius: 10px 10px;
   box-shadow: 1px 1px 10px 1px rgba(0.1, 0.1, 0.1, 0.1);
 }
 .van-card__title{
   font-size: 17px;
 }
</style>
